import { createStore } from 'redux';
import { makeAllReducer } from './StoreUtil';

// declare var window;
/** 
 * 生成store返回
*/
export default (initialState = {}, ...initReducer) => {

    // const enhancers = [];

    // if (process.env.NODE_ENV === 'development') {
    //     const devToolsExtension = window.devToolsExtension;
    //     if (typeof devToolsExtension === 'function') {
    //         enhancers.push(devToolsExtension());
    //     }
    // }

    let obj = {}
    initReducer.length && initReducer.forEach((item) => {
        obj[item.key] = item.reducer
    });

    const store = createStore(
        makeAllReducer(obj),
        initialState,
    );

    store.asyncReducers = {
        ...obj
    };

    return store;
}